---
category: Date Time
created: '2021-04-20'
title: Initialize the current date but set time to midnight
updated: '2021-10-13'
---

**JavaScript version**

```js midnightOfToday.js
const midnightOfToday = () => new Date(new Date().setHours(0, 0, 0, 0));
```

**TypeScript version**

```ts midnightOfToday.ts
const midnightOfToday = (): Date => new Date(new Date().setHours(0, 0, 0, 0));
```
